package cn.lhf.myblog.controller;

import cn.lhf.myblog.db.entity.User;
import cn.lhf.myblog.http.result.Result;
import cn.lhf.myblog.service.UserService;
import cn.lhf.myblog.utils.SHA512Utils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class TestController {
    @Resource
    UserService userService;

    @GetMapping("/tlogin")
    public User tlogin() {
        User user = userService.loginByName("admin", SHA512Utils.getSHA512("admin"));
        if (user == null) {
            return null;
        }
        user.setPassword(null);
        return user;
    }

    @GetMapping("/at")
    public Result at() {
        return new Result().setInfo(userService.getUserById(1));
    }
}
